package com.sgzn.sgpay.web.controller;

import com.sgzn.sgpay.model.request.SgsTodayIncomeRequest;
import com.sgzn.sgpay.model.response.SgsResultResponse;
import com.sgzn.sgpay.model.response.result.SgsTodayIncomeResult;
import com.sgzn.sgpay.service.SgsTodayIncomeService;
import com.sgzn.sgpay.web.controller.base.MerchantBaseController;
import com.sgzn.sgpay.web.handle.AssembleCommonHandle;
import com.sgzn.sgpay.web.request.Impl.TodayIncomeRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * 今日收益控制器
 * @author huangsenguang
 * @version Id: TodayIncomeController.java, v 0.1 2018/5/27 16:55 huangsenguang Exp $$
 */
@Slf4j
@Controller
public class TodayIncomeController extends MerchantBaseController {
    @Autowired
    private SgsTodayIncomeService sgsTodayIncomeService;
    @Resource
    private AssembleCommonHandle assembleCommonHandle;
    
    /**
     * 今日收益查询
     * @param request
     * @return
     */
    @RequestMapping("/merchant/income/todayIncome")
    @ResponseBody
    public SgsResultResponse<SgsTodayIncomeResult> queryIncomePreInfo(TodayIncomeRequest request) {
        super.setMchInfo(request);
        return this.sgsTodayIncomeService.query(assembleRequest(request));
    }

    private SgsTodayIncomeRequest assembleRequest(TodayIncomeRequest request) {
        SgsTodayIncomeRequest sgsTodayIncomeRequest = new SgsTodayIncomeRequest();
        this.assembleCommonHandle.assemble(request, sgsTodayIncomeRequest);
        return sgsTodayIncomeRequest;
    }
}

